package eric.mpab.dal.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;

import eric.mpab.dal.AccountRepository;
import eric.mpab.domain.AccountDO;
import eric.mpab.model.Account;
import eric.mpab.util.AccountAssembler;

@Repository
public class AccountRepositoryImpl implements AccountRepository {
	@Autowired
	private HibernateTemplate hibernateTemplate;

	public List<Account> getAllAccounts() {
		@SuppressWarnings("unchecked")
		List<AccountDO> topAccounts = hibernateTemplate.find("from AccountDO where parent is null");

		return AccountAssembler.assemble(topAccounts, true);
	}
}
